﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utility1;

namespace Thv.admin
{
    public partial class index : System.Web.UI.Page
    {
        #region Fields
        private string pageName;
        protected string template_path;
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                template_path = WebUtils.SystemUrl();
                Admin_tb listUser = (Admin_tb)Session[Global.SESS_USER];
                if (listUser == null)
                {

                    string link = template_path + "/admin/login.aspx";
                    Response.Redirect(link);
                }
                pageName = Utils.GetParameter("page", "home");
                getPageName(pageName);
            }
            catch (Exception) {
                string link = template_path + "/admin/login.aspx";
                Response.Redirect(link);
            }
        }

        private void getPageName(string pageName)
        {
            try
            {
                switch (pageName)
                {
                    case "home":
                        pageName = SiteNavigation.contronlHome;
                        break;
                    case "Kich-hoat":
                        pageName = SiteNavigation.contronlKichhoat;
                        break;
                    case "So-do":
                        pageName = SiteNavigation.contronlSodo;
                        break;
                    case "Thanh-vien":
                        pageName = SiteNavigation.contronlThanhvien;
                        break;
                    case "thong-ke":
                        pageName = SiteNavigation.contronlthongke;
                        break;
                    case "edit-product":
                        pageName = SiteNavigation.contronl_Product;
                        break;
                    case "QuanlySP":
                        pageName = SiteNavigation.contronl_QuanlySP;
                        break;
                    case "quanly-quangcao":
                        pageName = SiteNavigation.controlQuangcaosp;
                        break;
                }
                UserControl contentView = (UserControl)Page.LoadControl(pageName);
                phdContent.Controls.Add(contentView);
            }
            catch (Exception) { }
        }
    }
}